var oScorm = pipwerks.SCORM;  	// define a SCORM object to interface with PIPWerks code
    
	// This function initializes the course by connecting to the LMS and retrieving 
	// the student's name.
	function initCourse()
	{
		var lmsConnected = oScorm.init();
		
     	//alert( "lms connect " + lmsConnected );
		if( lmsConnected )
		{
            // always set the status to incomplete
			oScorm.set("cmi.lesson_status", "incomplete");
			oScorm.set("cmi.completion_status", "incomplete");
        	oScorm.set( "cmi.success_status", "unknown" );
		}
	}
 
	
    // Call this function at the very end of the course when the final
    // score has been calculated.
	function setScore( nCorrectResponses )
	{
     	//alert( "setscore  " +nCorrectResponses );
	    // Set the values and status here
        oScorm.set( "cmi.score.min", "0" );
        oScorm.set( "cmi.score.max", "100" );
        oScorm.set( "cmi.score.raw", nCorrectResponses );
        oScorm.set( "cmi.score.scaled", nCorrectResponses / 100 );
        oScorm.set( "cmi.completion_status", "completed" );
        
        if( nCorrectResponses >= 60 )
        {
        	oScorm.set( "cmi.success_status", "passed" );
        }
        
     	else
     	{
     		oScorm.set( "cmi.success_status", "failed" );
     	}
     	
     //	alert( "end " +nCorrectResponses );
	}
	
	// This function is called when the window is closed.  It saves and quits the course.
	function finishCourse()
	{
		oScorm.save();
		oScorm.quit();
	}